<?php
global $_GPC, $_W;
$GLOBALS['frames'] = $this->getMainMenu();
$uniacid=$_W['uniacid'];
$user_id=$_GPC['user_id'];
$where=" where uniacid={$uniacid}";
if(!empty($user_id)){
    $where .= " and user_id={$user_id}";
}
if($_GPC['time']){
  $start=strtotime($_GPC['time']['start']);
  $end=strtotime($_GPC['time']['end']);
  $where.=" and create_time >='{$start}' and create_time<='{$end}'";
}
$pageindex = max(1, intval($_GPC['page']));
$pagesize=10;
$sql="select *  from " . tablename("cjdc_point_log") ." ".$where." order by id DESC";
$select_sql =$sql." LIMIT " .($pageindex - 1) * $pagesize.",".$pagesize;
$list = pdo_fetchall($select_sql);
if(!empty($list)){
    foreach ($list as $key=>$value){
        $list[$key]['create_time'] = date('Y-m-d H:i',$value['create_time']);
        $list[$key]['user_id'] = pdo_fetchcolumn('select name from '.tablename('cjdc_user')." where id = {$value['user_id']}");
        switch ($value['type']){
            case 1:
                $type = '系统充值';
                break;
            case 2:
                $type = '会员签到';
                break;
            case 3:
                $type = '摇一摇';
                break;
            case 4:
                $type = '积分抵扣';
                break;
        }
        $list[$key]['type'] = $type;
    }
}
$total=pdo_fetchcolumn("select count(*) from " . tablename("cjdc_point_log") ." ".$where);
$pager = pagination($total, $pageindex, $pagesize);
include $this->template('web/userjf');